﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management;
using System.Text;
using WMI.NET.Abstracts;
using WMI.NET.CIM;

namespace WMI.NET.ComputerSystemHardware.MotherboardControllerPort
{
    /// <summary>
    /// The Win32_MotherboardDevice WMI class represents a device that contains the central components of the Windows computer system.
    /// </summary>
    public class Win32_MotherboardDevice : CIM_LogicalDevice
    {

        private string _PrimaryBusType;
        private string _RevisionNumber;
        private string _SecondaryBusType;

        /// <summary>
        /// Primary bus type of the motherboard.
        /// Example: "PCI"
        /// </summary>
        public string PrimaryBusType { get { return _PrimaryBusType; } }

        /// <summary>
        /// Revision number of the motherboard.
        /// Example: "00"
        /// </summary>
        public string RevisionNumber { get { return _RevisionNumber; } }

        /// <summary>
        /// Secondary bus type of the motherboard.
        /// Example: "ISA"
        /// </summary>
        public string SecondaryBusType { get { return _SecondaryBusType; } }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public Win32_MotherboardDevice(ManagementBaseObject mbo)
            : base(mbo)
        {
            _PrimaryBusType = mbo.GetStringValue("PrimaryBusType");
            _RevisionNumber = mbo.GetStringValue("RevisionNumber");
            _SecondaryBusType = mbo.GetStringValue("SecondaryBusType");
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public class GetWin32_MotherboardDevices : Win32Collection<Win32_MotherboardDevice>
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ReadOnlyCollection<Win32_MotherboardDevice> GetCollection()
        {
            List<Win32_MotherboardDevice> tempCollection = new List<Win32_MotherboardDevice>();

            foreach (var s in searcher.Get())
            {
                Win32_MotherboardDevice tempListItem = new Win32_MotherboardDevice(s);
                tempCollection.Add(tempListItem);
            }

            return tempCollection.AsReadOnly();
        }

        /// <summary>
        /// 
        /// </summary>
        public GetWin32_MotherboardDevices() : base("SELECT * FROM Win32_MotherboardDevice") { }

    }

}
